package com.zufe.ListTest;

import java.util.ArrayList;

public class EmployeeTest {
    public static void main(String[] args) {
        ArrayList<Employee> staff = new ArrayList<>();
        staff.add(new Employee("张三", 3000));
        staff.add(new Employee("李四", 3500));
        staff.add(new Employee("王五", 4000));
        staff.add(new Employee("赵六", 4500));
        staff.add(new Employee("田七", 5000));
        for (int i = 0; i < staff.size(); i++) {
            if(staff.get(i).getName().equals("王五")) {
                staff.set(i, new Employee("王小五", 4000));
            }
            if(staff.get(i).getName().equals("赵六")) {
                staff.remove(i);
                i--;
            }
            if(staff.get(i).getName().equals("田七")) {
                staff.get(i).setSalary(staff.get(i).getSalary() + 500);
            }
        }
        for (Employee employee : staff) {
            System.out.println("name=" + employee.getName() + ", salary=" + employee.getSalary());
        }
    }
}
